package com.cheng.example.atguigu.design_pattern.proxy.dynamic;

/*
 * @author 程帅
 * @createTime: 2020/10/15 22:53
 * @Created: with IntelliJ IDEA.
 */
public class Client {

    public static void main(String[] args) {

        //创建目标对象
        TeacherDao target = new TeacherDao();

        //给目标对象，创建代理对象，可以转成ITeacherDao
        ITeacherDao proxyInstance = (ITeacherDao)new ProxyFactory(target).getProxyInstance();

        // proxyInstance=class com.sun.proxy.$Proxy0内存中动态生成了代理对象
        System.out.println("proxyInstance=" + proxyInstance.getClass());

        //通过代理对象，调用目标对象的方法
        proxyInstance.teach();

        proxyInstance.sayHello("Tom");
    }
}
